package ling.archives.domain;

import com.easy.query.core.enums.RelationTypeEnum;
import com.easy.query.core.proxy.ProxyEntityAvailable;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.*;

import ling.archives.common.domain.entity.CU2Entity;
import ling.archives.common.domain.entity.IdEntity;
import ling.archives.domain.proxy.ArchiveProxy;
import lombok.*;
import com.easy.query.core.annotation.*;
import lombok.experimental.Delegate;

/**
 * 卷宗;
 * @author : He-LiangLiang@Outlook.com
 * @date : 2025-3-26
 */
@ApiModel(value = "卷宗",description = "")
@Table("ar_archive")
@EntityProxy
@Data
public class Archive extends CU2Entity.LongId implements IdEntity.IExtendInfo, Serializable,Cloneable, ProxyEntityAvailable<Archive , ArchiveProxy> {


    /** 1990年度\0002-*   (纸房乡1990年度001-541号)
     *
     * @return
     */
    public String gainFileDirPath(String basePath){
        if(basePath.endsWith("\\"))
        return basePath+getYear()+"年度\\"+getNum()+"-*";
        else return basePath+"\\"+getYear()+"年度\\"+getNum()+"-*";
    }

    /** 文档分类id */
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    @ApiModelProperty(value = "文档分类id",notes = "")
    private Long doccId ;


    /** 分类路径 */
    @ApiModelProperty(value = "分类路径",notes = "")
    private String doccPath ;

    @ApiModelProperty(value = "乡镇名称",notes = "")
    @EasyWhereCondition
    String townName;
    /** 档号;唯一 */
    @ApiModelProperty(value = "档号",notes = "唯一")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private String fullNum ;
    /** 案卷题名;纸房乡（镇）1990年度宅基地使用证存根001-541号 */
    @ApiModelProperty(value = "案卷题名",notes = "纸房乡（镇）1990年度宅基地使用证存根001-541号")
    @EasyWhereCondition
    private String title ;
    /** 全宗名称 */
    @ApiModelProperty(value = "全宗名称",notes = "")
    private String fullArchiveName ;
    /** 全宗号 */
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    @ApiModelProperty(value = "全宗号",notes = "")
    private String fullArchiveNum ;
    /** 年度 */
    @ApiModelProperty(value = "年度",notes = "")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private Integer year ;
    /** 保管期限，0永久 */
    @ApiModelProperty(value = "保管期限，0永久",notes = "")
    private Integer retentionPeriod ;
    /** 案卷号 */
    @ApiModelProperty(value = "案卷号",notes = "")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private String num ;
    /** 目录号 */
    @ApiModelProperty(value = "目录号",notes = "")
    private String dirNum ;
    /** 管理者 */
    @ApiModelProperty(value = "管理者",notes = "")
    private String manager ;
    /**  */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "",notes = "")
    private Date startDate ;
    /**  */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "",notes = "")
    private Date endDate ;
    /** 文件数 */
    @ApiModelProperty(value = "文件数",notes = "")
    private Integer totalFile ;
    /** 总页数 */
    @ApiModelProperty(value = "总页数",notes = "")
    private Integer totalPage ;
    /** 关键字 */
    @ApiModelProperty(value = "关键字",notes = "")
    @EasyWhereCondition
    private String keyword ;
    /** 部门说明 */
    @ApiModelProperty(value = "部门说明",notes = "")
    private String orgDescr ;
    /** 备注 */
    @ApiModelProperty(value = "备注",notes = "")
    private String reamrk ;
    /** 状态:0未归档,1已归档 */
    @ApiModelProperty(value = "状态:0未归档,1已归档",notes = "")
    @EasyWhereCondition(type = EasyWhereCondition.Condition.EQUAL)
    private String status ;
    /** 审批状态:0无审批锁定，其他值为锁定审批中 */
    @ApiModelProperty(value = "审批状态:0无审批锁定，其他值为锁定审批中",notes = "")
    private String approvalLock ;

    /** 审批记录ID */
    @ApiModelProperty(value = "审批记录ID",notes = "")
    private Integer approvalId ;

    @ApiModelProperty(value = "物理文件路径",notes = "")
    String filePath;
    //@ApiModelProperty(value = "内容信息")
    @Navigate(value = RelationTypeEnum.OneToMany,targetProperty = "archiveId", selfProperty = "id")
    List<ArchiveContent> contents=new ArrayList<>();


//    @Delegate
//    @ColumnIgnore
//    @Getter(AccessLevel.NONE)
//    @Setter(AccessLevel.NONE)
//    IExtendInfo ext=new ExtendInfo();

    @Getter(value = AccessLevel.PUBLIC,lazy = true)
    @Setter(AccessLevel.NONE)
    @ColumnIgnore
    private final HashMap<String, Object> extendMap=new HashMap<>();
}
